<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('专利列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>序号：</label>
                            <input type="text" name="numbers"/>
                        </li>
                        <!--  <li>
                              <label>专利类型：</label>
                              <input type="text" name="ptype"/>
                          </li>-->
                        <li>
                            <label>专利名称：</label>
                            <input type="text" name="pname"/>
                        </li>
                        <li>
                            <label>公开号：</label>
                            <input type="text" name="opens"/>
                        </li>
                        <li>
                            <label>申请人：</label>
                            <input type="text" name="sname"/>
                        </li>
                        <li>
                            <label>发明人：</label>
                            <input type="text" name="fname"/>
                        </li>
                        <li>
                            <label>其他参与人员：</label>
                            <input type="text" name="qname"/>
                        </li>
                        <li class="select-time">
                            <label>申请日：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginStime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endStime]"/>
                        </li>
                        <li class="select-time">
                            <label>授权日：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginQtime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endQtime]"/>
                        </li>
                        <li>
                            <label>赋分：</label>
                            <input type="text" name="grade"/>
                        </li>
                        <li>
                            <label>奖金：</label>
                            <input type="text" name="bonus"/>
                        </li>
                        <li>
                            <label>上传人：</label>
                            <input type="text" name="shname"/>
                        </li>
                        <li>
                            <label>附件：</label>
                            <input type="text" name="accessory"/>
                        </li>
                        <li>
                            <label>审批状态：</label>
                            <select name="status" th:with="type=${@dict.getType('sys_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>备案：</label>
                            <input type="text" name="onRecords"/>
                            <select name="onRecords" th:with="type=${@dict.getType('sys_records')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                </option>
                            </select>

                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:patent:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:patent:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:patent:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:patent:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('ruoyi:patent:edit')}]];
    var removeFlag = [[${@permission.hasPermi('ruoyi:patent:remove')}]];
    var datas = [[${@dict.getType('sys_records')}]];
    var datass = [[${@dict.getType('sys_status')}]];
    var prefix = ctx + "ruoyi/patentexa";

    $(function() {
        var options = {
            url: prefix + "/admin",
           /* createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",*/
            modalName: "专利",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'numbers',
                    title: '序号'
                },
                {
                    field: 'ptype',
                    title: '专利类型'
                },
                {
                    field: 'pname',
                    title: '专利名称'
                },
                {
                    field: 'opens',
                    title: '公开号'
                },
                {
                    field: 'sname',
                    title: '申请人'
                },
                {
                    field: 'fname',
                    title: '发明人'
                },
                {
                    field: 'qname',
                    title: '其他参与人员'
                },
                {
                    field: 'stime',
                    title: '申请日'
                },
                {
                    field: 'qtime',
                    title: '授权日'
                },
                {
                    field: 'grade',
                    title: '赋分'
                },
                {
                    field: 'bonus',
                    title: '奖金'
                },
                {
                    field: 'shname',
                    title: '上传人',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return '<a href="javascript:void(0)" onclick="chakan(\'' + row.userId + '\')">' + value + '</a>';
                    }
                },
                {
                    title: '查看文件',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.accessory==null||row.accessory==''){
                            actions.push('<p>未提交</p> ');
                            return actions.join('');
                        }else{
                            actions.push('<a href=\''+row.accessory+'\' target="_blank" rel="nofollow">查看文件</a> ');
                            return actions.join('');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'onRecords',
                    title: '备案',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'status',
                    title: '审批状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datass, value);
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.onRecords===2){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="consent(\'' + row.id + '\')"><i class="fa fa-user"></i>通过备案</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="refusal(\'' + row.id + '\')"><i class="fa fa-user"></i>驳回备案</a> ');
                        }else if(row.status===1) {
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="beApproved(\'' + row.id + '\')"><i class="fa fa-user"></i>通过审批</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="dismissTheApproval(\'' + row.id + '\')"><i class="fa fa-user"></i>驳回审批</a> ');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function consent(id) {
        $.modal.confirm("确认要通过申请备案吗?", function() {
            var url = prefix + "/consent";
            var data = { "id": id };
            $.operate.submit(url, "post", "json", data);
        });
    }

    function refusal(id) {
        $.modal.confirm("确认要驳回申请备案吗?", function() {
            var url = prefix + "/refusal";
            var data = { "id": id };
            $.operate.submit(url, "post", "json", data);
        });
    }

    function beApproved(id) {
        $.modal.confirm("确认要通过审批吗?", function() {
            var url = prefix + "/beApproved";
            var data = { "id": id };
            $.operate.submit(url, "post", "json", data);
        });
    }

    function dismissTheApproval(id) {
        $.modal.confirm("确认要驳回审批吗?", function() {
            var url = prefix + "/dismissTheApproval";
            var data = { "id": id };
            $.operate.submit(url, "post", "json", data);
        });
    }

    function detail(userId) {
        var url = prefix + '/detail/' + userId;
        $.modal.openTab("上传人信息", url);
    }
    function chakan(userId) {
        var url = prefix + '/chakan/' + userId;
        $.modal.openTab("查看详情", url);
    }
</script>
</body>
</html>